package com.anjho.bean;

import java.util.Date;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import org.primefaces.model.chart.CartesianChartModel;  
import org.primefaces.model.chart.ChartSeries; 

@ManagedBean(name = "reportBean")
@RequestScoped
public class ReportBean extends GenericBean {

	private static final long serialVersionUID = 1699763483127190743L;

	public ReportBean() {
		super();
		clearForm();
	}

	private Date startDate;
	private Date endDate;
	
	private CartesianChartModel saleChartModel;
	
	public void clearForm(){
		this.setSaleChartModel(new CartesianChartModel());
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
	
	public CartesianChartModel getSaleChartModel() {
		return saleChartModel;
	}

	public void setSaleChartModel(CartesianChartModel saleChartModel) {
		this.saleChartModel = saleChartModel;
	}

	public void createChartReport() {
        setSaleChartModel(new CartesianChartModel());
        ChartSeries sales = new ChartSeries();
        sales.setLabel("Vendas");
        
        sales.set("Junho", 334);
        sales.set("Julho", 222);
        sales.set("Agosto", 293);
        sales.set("Setembro", 308);
        sales.set("Outubro", 311);
        sales.set("Novembro", 189);
        
        this.getSaleChartModel().addSeries(sales);
	}
	
	public void onReportClick(){
		this.createChartReport();
	}

}
